package com.vietnam.power.persitence;

import java.io.Serializable;

import javax.persistence.*;

import com.vietnam.power.domain.Root;

import java.util.Date;
import java.util.List;


/**
 * The persistent class for the payment_method database table.
 * 
 */
@Entity
@Table(name="payment_method")
public class PaymentMethod implements Serializable, Root {
	private static final long serialVersionUID = 1L;
	private int id;
	private Date createdDate;
	private String description;
	private String name;
	private List<Transaction> transactions;

	public PaymentMethod() {
	}

	public PaymentMethod(int id) {
		this.id = id;
	}
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}


	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="created_date")
	public Date getCreatedDate() {
		return this.createdDate;
	}

	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}


	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}


	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}


	//bi-directional many-to-one association to Transaction
	@OneToMany(mappedBy="paymentMethod")
	public List<Transaction> getTransactions() {
		return this.transactions;
	}

	public void setTransactions(List<Transaction> transactions) {
		this.transactions = transactions;
	}

	public Transaction addTransaction(Transaction transaction) {
		getTransactions().add(transaction);
		transaction.setPaymentMethod(this);

		return transaction;
	}

	public Transaction removeTransaction(Transaction transaction) {
		getTransactions().remove(transaction);
		transaction.setPaymentMethod(null);

		return transaction;
	}

}